﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using Jermaine.Extensions;
using Jermaine.Serialization;

namespace Jermaine.Cache
{
    /// <summary>
    /// 存储对象
    /// </summary>
    [Serializable]
    public class TimedObject
    {
        public string Id { get; set; }

        public object Item { get; set; }

        public ExpiredTime ExpiredTime { get; set; }

        public TimedObject Mirror {
            get {
                return Cloning.DeepCopy<TimedObject>(this);
            }
        }

        public override string ToString() {
            var expiredTime = this.ExpiredTime == null ? "Undefined" : 
                this.ExpiredTime.DeadLine.ToString("yyyy/MM/dd HH:mm:ss");
            return String.Format("ExpiredTime:{0} - {1}", expiredTime, this.Item);
        }
    }
}
